<?php
namespace app\agent\servlet;

class WkOrderServlet extends BaseServlet
{
	public function __construct()
	{
		parent::__construct();
	}

	/**
	* 组装查询条件
	* @param array $data
	* @return array
	*/
	public function getWhere($data = [])
	{
		$where = [];
		
		if( empty($data) )
		{
			return $where;
		}

        if( empty($data['province']) === false )
        {
            $where[] = ['province', '=', $data['province']];
        }

        if( empty($data['city']) === false )
        {
            $where[] = ['city', '=', $data['city']];
        }

        if( empty($data['county']) === false )
        {
            $where[] = ['county', '=', $data['county']];
        }

        if ( empty($data['profit_stime']) === false && empty($data['profit_etime']) === false )
        {
            $where[] = ['paytime', 'BETWEEN TIME', [$data['profit_stime'], date('Y-m-d H:i:s', strtotime("{$data['profit_etime']}-1second"))]];
        }
		
		if( isset($data['status']) && $data['status'] !== '' )
		{
			$where[] = ['order.status','=',$data['status']];
		}
		
		return $where;
	}

	/**
	* 整理数据
	* @param array $data
	* @return array
	*/
	public function collating($data = [])
	{
		if( empty($data) )
		{
			return $data;
		}

		return $data;
	}
}